package ccgl.com.action;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ccgl.com.model.MUser;

public abstract class BaseServlet extends HttpServlet {
	protected ServletContext servletContext;

	public BaseServlet() {
		super();
	}
	
	
	@Override
	public void init(ServletConfig config) {
		servletContext = config.getServletContext();
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	protected int parseInt(String str) {
		if(str == null || str.trim().length() == 0) {
			return 0;
		}
		return Integer.parseInt(str);
	}
	
	protected MUser getWebUser(HttpServletRequest req) {
		return (MUser) req.getSession().getAttribute("user");
	}

}